import pandas as pd
import email as e
# 读取特定sheet页的表格数据
excel_file = 'TestRecord.xlsx'
sheet_name = 'E6_SW4.0RC2_smoke_test'  # 替换为您要读取的sheet页名称
df = pd.read_excel(excel_file, sheet_name=sheet_name)

# 将表格数据转换为HTML格式
html_table = df.to_html(index=False)

# 构建邮件内容
email_body = f"""
<html>
<head>
<style>
table, th, td {{
  border: 1px solid black;
  border-collapse: collapse;
  padding: 5px;
}}
</style>
</head>
<body>
{html_table}
</body>
</html>
"""
# 打印表格数据
recipient = "jimmy.tian1@magna.com"
cc_recipient = "jimmy.tian1@magna.com"
subject = sheet_name
body = email_body
e.save_email_to_draft(recipient, cc_recipient, subject, body)
